import java.util.Scanner;

public class Juxing {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.println("请输入矩形的高和宽");
        int h = input.nextInt();
        int s = input.nextInt();
        if (h >= 3 && s >= 3) {
            for (int j = 1; j <= h; j++) {
                for (int i = 1; i <= s; i++) {
                    if (j== 1 || j== h) {
                        System.out.print("*");
                    } else if (i==1||i==s){
                        System.out.print("*");
                    }else {
                        System.out.print(" ");}
                }
                System.out.println();
            }
        } else {
            System.out.println("请重新输入");
        }

    }
}
